package com.hspedu.homework;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/26
 * @time 19:05
 */
public class Homework01 {
    public static void main(String[] args) throws IOException {

        File file = new File("D:\\BaiduNetdiskDownload\\韩顺平2021基础学Java\\mytemp");

        boolean exists = file.exists();

        if (exists){
            System.out.println("文件已存在");
        }else {
            file.mkdir();
            File file1 = new File("D:\\BaiduNetdiskDownload\\韩顺平2021基础学Java\\mytemp\\hello.txt");
            file1.createNewFile();

            FileWriter fileWriter = new FileWriter(file1);
            fileWriter.write("hello,world!");

            if (fileWriter != null){
                fileWriter.close();
            }

            System.out.println("文件已创建");
        }

    }
}
